import Vue from 'vue';
import store from './store'; // api: https://github.com/vuejs/vuex
import ElementUI from 'element-ui';
import CtciComponent from '@/components';
import '@/icons'; // api: http://www.iconfont.cn/
import '@/element-ui-theme';
import '@/assets/scss/index.scss';
import 'vue2-animate/dist/vue2-animate.min.css';
import Router from './router';
import Main from './main.vue';
import 'nprogress/nprogress.css';
import Bus from '@/utils/bus';
import { requestData } from '@/api';
// 按钮权限指令
import hasPermission from '@/utils/hasPermission';
import { JSONToExcelConvertor } from './assets/js/JSONToExcelConvertor';
import { chartColors } from './assets/js/chart-colors';
// import scroll from 'vue-seamless-scroll';
import VueCookie from 'vue-cookie';
import moment from 'moment';
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts;
// import 'element-ui/lib/theme-chalk/index.css';
// 这里是进行了汉化 不写这句默认格式是外国的
moment.locale('zh-cn');
Vue.prototype.$moment = moment;
Vue.prototype.JSONToExcelConvertor = JSONToExcelConvertor;
Vue.prototype.chartColors = chartColors;
// table 操作栏使用v-hasPermission指令控制按钮权限有性能问题
Vue.prototype.$hasPermission = buttoncode => store.state.permission.buttonList
  .map(v => v.buttoncode).includes(buttoncode);
Vue.use(VueCookie);
Vue.use(hasPermission);
// Vue.use(scroll);
Vue.prototype.$ajax = requestData;
Vue.use(ElementUI, {
  size: 'medium' // set element-ui default size
});
Vue.use(CtciComponent);
Vue.prototype.$bus = Bus;

// 创建和挂载根实例。
// 记得要通过 router 配置参数注入路由，
// 从而让整个应用都有路由功能
new Vue({
  el: '#app',
  render: h => h(Main),
  store,
  router: Router
});

